package com.example.config;

import com.example.filter.AdminFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.servlet.Filter;
import javax.servlet.FilterRegistration;

/**
 * 过滤器配置
 */
@Configuration
public class AdminFilterConfig {
    @Bean
    public AdminFilter adminFilter(){
        return new AdminFilter();
    }
    @Bean(name="adminConfigFilt")
    public FilterRegistrationBean adminConfigFilter(){
    FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
    filterRegistrationBean.setFilter(adminFilter());
    filterRegistrationBean.addUrlPatterns("/shop/*");
        filterRegistrationBean.setName("adminConfigFilt");
        return filterRegistrationBean;
    }

}
